package com.nothing.count.service;

import com.nothing.count.dao.CountDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
* 数据统计服务层
* */
@Service
public class CountService {
    @Resource
    CountDao countDao;

    //统计员工工资和奖金数据
    public List countEmpSal(){
        return countDao.queryBySql("select ename,sal,comm from emp ");
    }

    //统计部门总工资和奖金数据
    public List countDeptSal(){
        return countDao.queryBySql("select dname , sum(sal) as totalSal , sum(comm) as totalComm from emp E\n" +
                "right join dept D on E.deptno = D.deptno \n" +
                "group by dname ");
    }

    //统计部门人数分布
    public List countDeptNum(){
        return countDao.queryBySql("select dname , count(*) as totalCount from emp E\n" +
                "right join dept D on E.deptno = D.deptno \n" +
                "group by dname ");
    }
}
